<?php
namespace app\index\model;
use \think\Model;
use \think\Db;
class BaseModel{
   

    //创建参数(包括签名的处理)
    function createParam ($paramArr,$showapi_secret) {
         $paraStr = "";
         $signStr = "";
         ksort($paramArr);
         foreach ($paramArr as $key => $val) {
             if ($key != '' && $val != '') {
                 $signStr .= $key.$val;
                 $paraStr .= $key.'='.urlencode($val).'&';
             }
         }
         $signStr .= $showapi_secret;//排好序的参数加上secret,进行md5
         $sign = strtolower(md5($signStr));
         $paraStr .= 'showapi_sign='.$sign;//将md5后的值作为参数,便于服务器的效验
         return $paraStr;
    }
    public static function insert($table, $insert_data, $create_time='0')
    {
        if($create_time){
            $insert_data['create_time'] = date("Y-m-d H:i:s");
        }
        $id = Db::name($table)->insertGetId($insert_data);
        return $id;
    }
}